package com.objecteffects.ilmp.web.action;

import java.io.IOException;
import java.util.List;
import java.util.Set;

import javax.inject.Inject;

import com.objecteffects.ilmp.util.logger.InjectLogger;
import com.objecteffects.ilmp.web.utils.LoginRequired;
import com.objecteffects.ilmp.web.utils.NotLikedPost;

import org.slf4j.Logger;

import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.Resolution;

/**
 * @author Rusty Wright
 */
@LoginRequired
public class PostsActionBean extends BaseActionBean {
    @InjectLogger
    private Logger log;

    private static final String METHOD = "posts";

    private final PostsActionBeanSub postsActionBeanSub;

    @Inject
    PostsActionBean(final PostsActionBeanSub _postsActionBeanSub) {
        this.postsActionBeanSub = _postsActionBeanSub;
    }

    @DefaultHandler
    public Resolution startHandler() throws IOException {
        this.postsActionBeanSub.setContext(this.getContext());

        return this.postsActionBeanSub.startHandler(PostsActionBean.METHOD,
                                                    IlmpView.POSTS);
    }

    public Resolution next() throws IOException {
        this.postsActionBeanSub.setContext(this.getContext());

        return this.postsActionBeanSub.next(true, this.getClass());
    }

    public Resolution cancel() {
        this.setContext(this.getContext());

        return this.postsActionBeanSub.cancel();
    }

    public Set<Long> getSelectedPosts() {
        return this.postsActionBeanSub.getSelectedPosts();
    }

    public void setSelectedPosts(final Set<Long> _selectedPosts) {
        this.postsActionBeanSub.setSelectedPosts(_selectedPosts);
    }

    public List<NotLikedPost> getPosts() {
        return this.postsActionBeanSub.getPosts();
    }

    public int getOffset() {
        return this.postsActionBeanSub.getOffset();
    }
}
